package com.yumis.service.modules.shop.controller;

import com.yumis.service.common.enums.HttpState;
import com.yumis.service.common.vo.Response;
import com.yumis.service.model.pojo.Shop;
import com.yumis.service.model.pojo.ShopPosition;
import com.yumis.service.modules.shop.service.ShopPositionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Slf4j
@RestController
@RequestMapping("shopposition")
public class ShopPositionController {
    @Autowired
    private ShopPositionService shopPositionService;
    /**
     * 新增店铺信息
     * @param shopPosition
     * @return
     */
    @PostMapping("addShopPosition")
    public ResponseEntity<Response> addShopPosition(@Valid ShopPosition shopPosition){
        shopPositionService.addShopPosition(shopPosition);
        return ResponseEntity.ok().body(Response.buildResponse(HttpState.OK));
    }
    /**
     * 根据id删除
     * @param id
     * @return
     */
    @PostMapping("deleteShopPositionById")
    public ResponseEntity<Response> deleteShopPositionById(@RequestParam("id") Long id){
        shopPositionService.deleteShopPositionById(id);
        return ResponseEntity.ok().body(Response.buildResponse(HttpState.OK));
    }
    /**
     * 根据id查询
     * @param id
     * @return
     */
    @PostMapping("queryShopPositionById")
    public ResponseEntity<Response> queryShopPositionById(@RequestParam("id") Long id){
        return ResponseEntity.ok().body(Response.buildResponse(HttpState.OK,shopPositionService.queryShopPositionById(id)));
    }

    /**
     * 修改
     * @param shopPosition
     * @return
     */
    @PostMapping("updateShopPosition")
    public ResponseEntity<Response> updateShopPosition(@Valid ShopPosition shopPosition){
        shopPositionService.updateShopPosition(shopPosition);
        return ResponseEntity.ok().body(Response.buildResponse(HttpState.OK));
    }
}
